const db=require('../../db/index')

exports.getProduct=(req,res)=>{
    const sql=`select * from product order by editTime DESC`
    db.query(sql,(err,results)=>{
        if(err) return res.cc(err)
        // if(results)
        console.log(results);
        res.send({
            status:0,
            message:'OK',
            product:results
        })
    })
}

// 获取当前产品信息
exports.getCurrentProduct=(req,res)=>{
 const sql=`select * from product where id=?`
 db.query(sql,req.params.id,(err,results)=>{
    if(err) return res.cc(err)
    if(results.length==0) return res.cc('获取当前数据失败')
    res.send({
        status:0,
        message:'OK',
        currentProduct:results
    })
 })
}